<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <title>提现</title>
  <link rel="stylesheet" type="text/css" href="./css/api.css" />
  <link rel="stylesheet" type="text/css" href="./css/aui.css" />
  <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
  <link rel="stylesheet" type="text/css" href="./css/styleold.css" />
  <script type="text/javascript" src="./script/api.js"></script>
  <script type="text/javascript" src="./script/aui-tab.js" ></script>
  <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
  <script type="text/javascript" src="./script/aui-slide.js"></script>
  <script type="text/javascript" src="./script/base.js"></script>
  <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
  <script type="text/javascript">
    function closeWin(){
      api.closeWin();
    };
   //  function closeFrame(){
   //   api.setFrameGroupIndex({
   //    name: 'nav',
   //    index: 2,
   //    reload: true,
   //  });
   //   var setSele = 'changeSelect();';
   //   api.execScript({
   //    name: 'home',
   //    script: setSele,
   //  });
   //   api.closeFrame({
   //    name: 'sh_bank_withdraw'
   //  });
   // };
 </script>
</head>
<body>
 <!-- 头部 -->
 <header class="aui-bar aui-bar-nav" id="topbar">
   <a class="aui-pull-left aui-btn" onclick="closeWin();">
    <span class="aui-iconfont aui-icon-left"></span>
  </a>
  <div class="aui-title">提现</div>
</header>
<form id="withdrawForm" action="http://www.big-wealth.com/index.php?ctl=hrb&act=cash" method="post">
  <div class="sh-bank-d">
    <h3>可提现金额(元) : <span id="money"></span></h3>
    <ul>
      <input type="hidden" name="agent" value="h5">
      <input type="hidden" name="userid" id="userid">
      <li>
        <div class="aui-col-xs-3">提现金额</div>
        <div class="aui-col-xs-5"><input type="tel" name="transAmt" id="moneyNum" placeholder="请填写提现金额" maxlength="12" style="height:auto;">
          <div class="check" id="checkWithdraw"></div>
        </div>
        <div class="aui-col-xs-4"></div>
      </li>
    </ul>
    <div class="aui-btn aui-btn-success aui-btn-block aui-btn-sm" onclick="withdraw()">确认提现</div>
  </div>
</form>
</body>
<script type="text/javascript">
  apiready = function(){

      // 可提现金额
      cash = api.pageParam.cash;
      money = api.pageParam.money;
      // var money = $api.getStorage('money');
      var moneyEle = document.getElementById("money");
      moneyEle.innerHTML = money - cash;
    }

    $("#moneyNum").blur(function(){
      var moneyEle = $api.byId('moneyNum');
      var moneyNum = moneyEle.value;
  var money = toDecimal2(moneyNum);
      $("#moneyNum").val(money);
});


    function withdraw(){

      withdrawID = api.pageParam.withdrawID;

      var moneyEle = $api.byId('moneyNum');
      var moneyNum = moneyEle.value;
      // 提现金额不能为空
      if (!moneyNum) {
        $api.byId('checkWithdraw').innerText = '提现金额不能为空';
        return false;
      }else{
        $api.byId('checkWithdraw').innerText = '';
      }

      api.ajax({
        url: webAddress + '/index.php?ctl=deal&act=cash_yuebao',
        method: 'post',
        data: {
          values: {
            id: withdrawID,
            cash:moneyNum,
            ajax: 1,
          },
        }
      },function(ret, err){
        if (ret) {
          if (ret.status == 0) {
            alert(ret.info);
            return false;
          } else {
            api.toast({
              msg: '提现成功',
              duration: 2000,
              location: 'middle',
              global: true,

            });
            var refreshData = 'updateData();';
            api.execScript({
              name: 'zhitou-list',
              script: refreshData,
            });
            api.closeWin();
          }
        } else {
          alert(err.msg);
        }
      });


    //   var moneyEle = $api.byId('moneyNum');
    //   var moneyNum = moneyEle.value;
    // // 提现金额不能为空
    // if (!moneyNum) {
    //   $api.byId('checkWithdraw').innerText = '提现金额不能为空';
    //   return false;
    // }else{
    //   $api.byId('checkWithdraw').innerText = '';
    // }

    //   // 提交表单
    //   var form = document.getElementById("withdrawForm");
    //   form.submit();
    //   api.toast({
    //     msg: '正在前往哈行存管系统...',
    //     duration: 2000,
    //     location: 'middle'
    //   });
  }
</script>
</html>
